package com.ror.java.se.file;

import java.io.File;
import java.util.stream.Stream;

/*
    获取当前模块的assets/file下的所有txt文件
 */

public class Demo02 {
    public static void main(String[] args) {
        File assetsDir = new File("assets", "file");
        //file-filter
        File[] files1 = assetsDir.listFiles(f -> f.isFile() && f.getName().endsWith(".txt"));
        if (files1 != null) {
            Stream.of(files1).forEach(System.out::println);
        }
        System.out.println("============================");
        //filename-filter
        File[] files2 = assetsDir
                .listFiles((dir, name) -> new File(dir, name).isFile() && name.endsWith(".txt"));
        if (files2 != null) {
            Stream.of(files2).forEach(System.out::println);
        }
    }
}
